import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 斐波那契数组
 * User: DELL
 * Date: 2024-05-18
 * Time: 11:54
 */
public class Main4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] num = new int[n];
        int min = 0;
        int max = 0;
        int res = 1000010;
        for (int i = 0; i < n; i++) {
            num[i] = scanner.nextInt();
            min = Math.min(min, num[i]);
            max = Math.max(max, num[i]);
        }
        for (int i = min; i < max; i++) {
            int count = 0;
            if (num[0] != i) {
                count++;
            }
            if (num[1] != i) {
                count++;
            }
            int temp1 = i;
            int temp2 = i;
            for (int j = 2; j < n; j++) {
                if (temp1 + temp2 > max) {
                    count += n - j;
                    break;
                }
                if (num[j] != temp1 + temp2) {
                    count++;
                }
                int temp = temp1 + temp2;
                temp1 = temp2;
                temp2 = temp;
            }
            res = Math.min(res, count);
        }
        System.out.println(res);
    }
}
